﻿@using MudBlazor.Utilities
@using System;
@using System.IO;
@using System.Linq;
@using System.Text.RegularExpressions;
@using System.Threading.Tasks;
@using Microsoft.AspNetCore.Components;
@using MudBlazor.Docs.Extensions;
@using MudBlazor.Docs.Models;


@if (Codes != null || ChildContent != null)
{
    <div class="@Classname">
        @if (Codes != null || ChildContent != null)
        {
            <MudToolBar Class="@ToolbarClassname">
                @if(Codes != null)
                {
                    @foreach (var codefile in Codes)
                    {
                        <MudButton Class="@GetActiveCode(codefile.code)" OnClick="@(() => SetActiveCode(codefile.code))" Size="Size.Small">@codefile.title</MudButton>
                    }
                }
                <MudSpacer/>
                @if (_hasCode && ChildContent != null)
                {
                    <MudTooltip Text="Online Playground" Arrow="true" Color="Color.Dark" Placement="Placement.Top" Delay="300" Duration="500" ShowOnFocus="false">
                        <MudButton OnClick="RunOnTryMudBlazor" StartIcon="@Icons.Material.Rounded.PlayArrow" IconColor="Color.Success" Color="Color.Default" Size="Size.Small">Run</MudButton>
                    </MudTooltip>
                    <MudButton OnClick="OnShowCode" StartIcon="@(ShowCode ? @Icons.Material.Rounded.CodeOff : Icons.Material.Rounded.Code)" Color="Color.Default" Size="Size.Small">
                        @(ShowCode ? "Hide code" : "Show code")
                    </MudButton>
                }
            </MudToolBar>
        }
        @if (ChildContent != null)
        {
            <div class="@InnerClassname">
                @ChildContent
            </div>
        }
    </div>
}
@if (_hasCode)
{
    <div class="@SourceClassname">
        <div class="docs-section-source-container" id="@_snippetId">
            @CodeComponent(_activeCode)
        </div>
        <MudIconButton Icon="@Icons.Material.Outlined.FileCopy" Size="Size.Small" Class="copy-code-button" @onclick="CopyTextToClipboard" />
    </div>
}